//获取URL传递的参数
function getParm(word){
      var url=window.location.search;//获取url参数
      url=url.substr(1,url.length);
      if(url.indexOf('&')==-1){
        brr=url.split('=');
            if(brr[0]==word){
               return brr[1];
            }
      }else{
        var arr=url.split('&');
        var brr='';
        for(var i=0;i<arr.length;i++){
            brr=arr[i].split('=');
            if(brr[0]==word){
                return brr[1];
            }
        }   
       } 
    }
var goods_id=getParm('goods_id');  
var order_id=getParm('order_id');   
//获取商品信息
var userid=myinfo['userid'];
var random=myinfo['random'];
var ht='';
var taobao='';
$.ajax({ 
      data:{goods_id:goods_id},
      type:'post',  
      url : myconfig['api']+'goods_show',  
      dataType : 'json',  
      jsonp:"jsoncallback",  
      success  : function(data) { 
        var money=parseInt(data.lists.goods_price)+parseInt(data.lists.goods_bonus); 
        ht+='<div class="part part1">';
        ht+='<div class="part1L">';
        ht+='<img src=http://localhost/'+data.lists.thumb+'>';
        ht+='</div>';
        ht+='<div class="part1R">';
        ht+='<h3 class="yc">'+data.lists.title+'</h3>';
        ht+='<p class="yc">下单：<b>￥'+data.lists.goods_price+'</b>';
        if(data.lists.protype==3){
        ht+='<em>红包任务</em>';
        }else if(data.lists.protype==2){
        ht+='<em>拍A发B</em>';
        }           
        ht+='<p class="yc">返还：<b>￥'+money+'</b>（含红包<b>￥'+data.lists.goods_bonus+'</b>）</p>';
        ht+='</div>';
        ht+='</div>';
        ht+='<div class="order_xq_tip">';
        var data0=data.lists;
        $.ajax({ 
              data:{order_id:order_id,userid:userid,random:random},
              type:'post',  
              url : myconfig['api']+'order_info_one',  
              dataType : 'json',  
              jsonp:"jsoncallback",  
              success  : function(data) { 
                    var end_time=data0.end_time;
                    var taobao=data.data.taobao;
                    ht+='<p>提示：<b>'+data.data.cause+'</b></p>';
                    ht+='<p>请使用绑定的淘宝“<b>'+taobao+'</b>”下单</p>';
                    ht+='<p>未在<b><span id="day_show"></span>天<span id="hour_show"></span>小时<span id="minute_show"></span>分<span id="second_show"></span>秒</b>前下单，将失去资格！</p>';
                    ht+='</div>';
                    //如果是红包试用  并不确定protype的值是多少时才是红包试用
                    if(data0.protype==2){
                    ht+='<div class="part part2">';
                    ht+='<i class="icon ion-android-person" style="font-size:18px;color:#aaaaea"></i>红包试用<span>完成任务将获得：<b>'+data0.goods_bonus+'红包</b></span>';
                    ht+='</div>';
                    }                   
                    ht+='<div class="order_xq_tip">';
                    if(data0.type=='search'){
                    ht+='<p><i class="icon ion-ios-list-outline" style="color:#7687f1"></i>搜索下单</p>';
                    }else if(data0.type=='general'){
                    ht+='<p><i class="icon ion-ios-list-outline" style="color:#7687f1"></i>普通下单</p>';
                    }else if(data0.type=='taokouling'){
                    ht+='<p><i class="icon ion-ios-list-outline" style="color:#7687f1"></i>淘口令下单</p>';
                    }else if(data0.type=='qrcode'){
                    ht+='<p><i class="icon ion-ios-list-outline" style="color:#7687f1"></i>扫码下单</p>';
                    }
                    ht+='</div>';
                    ht+='<div class="part part3">';
                    if(data0.type=='search'){
                    //商品所在平台
                    var platform='';
                    if(data0.source==1){
                      platform='淘宝';
                    }else if(data0.source==2){
                      platform='天猫';
                    }else if(data0.source==3){
                      platform='京东';
                    }
                    ht+='<h3><span>活动详情</span></h3>';
                    ht+='<p>1、打开<b>'+platform+'</b>首页，根据<b>'+data0.goods_rule["sort"]+'</b>排名搜索关键词<b>'+data0.goods_rule.keyword+'</b></p>';
                    ht+='<p>2、宝贝位置大约在<b>'+data0.goods_rule.address+'</b></p>';
                    ht+='<p>3、核对旺旺<b>'+data0.goods_rule.keyword2+'</b></p>';
                    }else if(data0.type=='taokouling'){
                    ht+='<p><em>长按复制下面淘口令到手机淘宝！</em></p>';
                    ht+='<p><b>'+data0.taokouling+'</b></p>';
                    }else if(data0.type=='qrcode'){
                    ht+='<p><em>此任务请在PC端完成，或用另一个手机扫码此二维码！</em></p>';
                    ht+='<p><img src='+data0.goods_search_albums[0]+'></p>';
                    }
                    ht+='<h3><span>注意事项</span></h3>';
                    ht+='<p><em>违反平台相关规定,不按要求下单,可能会被拒绝返款,冻结帐号</em></p>';
                    ht+='<h3><span>商家说明'+data0.goods_content+'</span></h3>';
                    ht+='</div>';
                    ht+='<div class="tk"></div>';
                    ht+='<div class="order_xq_footer part">';
                    ht+='<ul>';
                    if(data0.type=='qrcode'||data0.type=='search'||data0.type=='taokouling'){
                    ht+='<li class="disable">已申请过</li>'; 
                    }                        
                    if(data0.type=='general'){
                    ht+='<li class="order_go red_kuang">';
                    ht+="<a href="+data0.goods_url+">去下单</a>";
                    ht+='</li>';  
                    }                    
                    ht+='<li class="red_kuang"><a href="trial_order.html">查看我的订单</a></li>';
                    ht+='</ul>';
                    ht+='</div>';
                    $('.order_xq').append(ht);
                    timer(end_time);

                    
                    
              },
              error:function(){},
        });
        
        
        
        
                                              
      },
      error: function(data) {                              
            alert('出错了');                             
      },  
});


function timer(end_time){
    
    tim=window.setInterval(function(){

    var intDiff=end_time-parseInt(new Date().getTime()/1000);
    var day=0,
        hour=0,
        minute=0,
        second=0;//时间默认值        
    if(intDiff > 0){
        day = Math.floor(intDiff / (60 * 60 * 24));
        hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
        minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
        second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
    
        if (minute <= 9) minute = '0' + minute;
        if (second <= 9) second = '0' + second;    
        $('#day_show').html(day);
        $('#hour_show').html(hour);
        $('#minute_show').html(minute);
        $('#second_show').html(second);
        
    }

    }, 1000);
} 